/**
 * 
 */
package gpl.scotlandyard.android.activities;

import gpl.scotlandyard.android.R;
import gpl.scotlandyard.android.controllers.SplashController;
import android.content.pm.PackageInfo;
import android.content.pm.PackageManager;
import android.content.pm.PackageManager.NameNotFoundException;
import android.os.Bundle;
import android.view.Menu;
import android.view.MenuItem;
import android.view.View;
import android.view.View.OnClickListener;
import android.widget.Button;
import android.widget.Toast;

/** @author Norbert */
public class SplashActivity extends AbstractActivity {
  @Override
  public void onCreate(Bundle savedInstanceState) {
    super.onCreate(savedInstanceState);
    setContentView(R.layout.home);
    setController(SplashController.getInstance());
    getController().setActivity(this);

    Button but = (Button) findViewById(R.id.splash_but_quick_track);
    but.setOnClickListener(new OnClickListener() {
      @Override
      public void onClick(View v) {
        getController().playQuickTrackMode();
      }
    });

    but = (Button) findViewById(R.id.splash_but_path_finder);
    but.setOnClickListener(new OnClickListener() {
      @Override
      public void onClick(View v) {
        getController().playPathFinderMode();
      }
    });
    PackageManager manager = this.getPackageManager();
    try {
      PackageInfo info = manager.getPackageInfo(this.getPackageName(), 0);
      Toast.makeText(
          this,
          "PackageName = " + info.packageName + "\nVersionCode = " + info.versionCode + "\nVersionName = " + info.versionName
              + "\nPermissions = " + info.permissions, Toast.LENGTH_SHORT).show();
    } catch (NameNotFoundException e) {
      e.printStackTrace();
    }
    getController().onViewCreated();
  }

  /** Shows two buttons on screen to choose using mode. */
  public void showButtons() {
    View view = findViewById(R.id.splash_but_quick_track);
    view.setEnabled(true);
    view = findViewById(R.id.splash_but_path_finder);
    view.setEnabled(true);
    view.invalidate();
  }

  @Override
  public SplashController getController() {
    return (SplashController) super.getController();
  }

  @Override
  protected void onCreateOptionsMenuChild(Menu menu) {
    // do nothing
  }

  @Override
  protected boolean onOptionsItemSelectedChild(MenuItem item) {
    // do nothing
    return false;
  }

}
